package com.itbaizhan.dao.impl;

import com.itbaizhan.dao.OrderDao;
import com.itbaizhan.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author spf
 * @date 2024/3/8
 * @time 17:18
 */

@Repository
public class OrderDaoImpl implements OrderDao {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public List<Order> getOrder(String user) {
        Query query = new Query();
        query.addCriteria(Criteria.where("username").is(user));
        return mongoTemplate.find(query, Order.class);
    }
}
